
 const app = getApp()

Page({

      /**
       * 页面的初始数据
       */
      data: {
        floor:0,
        workshop_total:0,
        slider:[],
        imageList:[
          'http://pic.qalex.com/file/USlSqkVA5NZlMrCAmItyp9B77vF9Qdf0EgIAoYs1.png',
          'http://pic.qalex.com/file/9PvhUndWkzORtgI3qVJBcmU49K5x39Z5Tylnw3XE.png',
          'http://pic.qalex.com/file/A5pjjWUnamHOwlZErttr4QsLaIwLEN7SUT45sEwV.png',
          'http://pic.qalex.com/file/DBOOolLSBoHL0Pr6GCL8O6lIIPrHiaZJp5RhHFj4.png',
          'http://pic.qalex.com/file/hYlJcJ1ZAJF83nVZXtfUqYree253XUuIFtQJ2RZY.png',
          'http://pic.qalex.com/file/X3ns0Drs4rSmcdjbawoanCSj7hWxpgwg9IauxvmQ.png',
          'http://pic.qalex.com/file/3SPSW3EogQuNbg7rK1JjBatJyzSMQziuGk17s236.png',
          'http://pic.qalex.com/file/tqJxG7dLmNxCykHMVATL6sApyhWlKfzMQsKjc9zo.png'
        ],
        img1:0,
        img2:2,
        img3:4,
        img4:6,
        pull:false,
        show:false,
        isFixed:false,
        content: [],
        user: '',
        mobile: '',
        px: ['发布时间从新到旧', '发布时间从旧到新', '价格由低到高', '价格由高到低'], //排序列表内容
    pxsort: [
      { sort_key: 'created_at', sort: 'desc' },
      { sort_key: 'created_at', sort: 'asc' },
      { sort_key: 'rent', sort: 'asc' },
      { sort_key: 'rent', sort: 'desc' },
    ],
    areaList: [
      {
        id: 1,
        value: "1000㎡以下"
      },
      {
        id: 2,
        value: "1000-3000㎡"
      },
      {
        id: 3,
        value: '3000-6000㎡'
      },
      {
        id: 4,
        value: '6000-10000㎡'
      },
      {
        id: 5,
        value: '10000㎡以上'
      },
     
    ],//面积
    area_title: '面积',
    statusList: [
      '有效',
      '无效',
      '已租',
      '我租',
      '已售',
      '我售',
    ],

    industryList: [],
    selectIndustry: [],
    hangyeList: [],
    selectHangye: [],
    tagsList: [],
    selectTags: [],
    statusIndex: '',
    more_title:'点击加载更多厂房...',
    qyopen: false, //点击地铁区域筛选滑动弹窗显示效果，默认不显示
    nzopen: false, //价格筛选弹窗
    pxopen: false, //排序筛选弹窗
    stopen: false,
    nzshow: true,
    pxshow: true,
    stshow: true,
    isfull: false,
    qyshow: true, //用户点击闭关区域的弹窗设置，默认不显示
    areaIndex: '',
    status_title: '筛选',
    quyu_title: '区镇',
    cityleft: ['区域'], //获取地铁区域的下拉框筛选项内容
    citycenter: {}, //选择地铁区域左边筛选框后的显示的中间内容部分
    cityright: {}, //选择地铁区域的中间内容部分后显示的右边内容
    select1: '', //地铁区域选中后的第二个子菜单，默认显示地铁下的子菜单
    select2: '', //地铁区域选择部分的中间
    select3: '', //地铁区域选择部分的右边
     pxIndex: '', //排序内容下拉框，默认第一个
    pxTitle: '排序',
    shownavindex: '',
    // 价格筛选框设置
    leftMin: 0,
    leftMax: 10000, //左边滑块最大值
    rightMin: 0, //右边滑块的最小值
    rightMax: 10000, //右边滑块最大值
    leftValue: 1000, //左边滑块默认值
    rightValue: 6000, //右边滑块默认值
    leftPer: '50', //左边滑块可滑动长度：百分比
    rightPer: '50', //右边滑块可滑动长度

    workshop: [],
    workshop_next: 1,
    page: 1,
    hangye: 0,
    industry: 0,
    tags: 0,
    sort_key: 'id',
    sort: 'desc',
    province_id: 0,
    status: '',
    city_id: 0,
    qu_id: 0,
    purpose: 0,
        purposeList: [],
        selectPurpose: [],
    area: 0,
    items: [
      {
        type: 'filter',
        label: '筛选',
        value: 'filter',
        children: [
          {
            type: 'checkbox',
            label: '类型',
            value: 'industry',
            children: [{
              label: '运动',
              value: '1',
            },
            ],
          },
          {
            type: 'checkbox',
            label: '适用行业',
            value: 'hangye',
            children: [

            ]
          },
          {
            type: 'checkbox',
            label: '标签',
            value: 'tags',
            children: [

            ]
          },

        ],
        groups: ['001', '002', '003'],//判断元素是否同组
      },
    ],

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(1111)
      console.log(options)
 
    if (app.globalData.user && app.globalData.user != null) {
      //获取用户信息
      this.setData({
        user: app.globalData.user,
        mobile: app.globalData.user.mobile
      })
    } else {
      app.emptyUserCallback = user => {
        if (user != null) {
          this.setData({
            user: app.globalData.user,
            mobile: app.globalData.user.mobile
          });

        }
      }
    }
    //城市
    wx.request({
      url: app.globalData.apiurl + "workshop_city",
      method: 'GET',
      success: res => {
        if (res.statusCode == 200) {
          console.log(res)
          this.setData({
            cityleft: res.data
          })
        }
      }
    })
    wx.request({
      url: app.globalData.apiurl + "workshop_purpose",
      method: 'GET',
      success: res => {
        console.log(res)
        if (res.data.code == 0) {
          this.setData({
            purposeList: res.data.data
          })
        }
      }
    })
    //slider
    wx.request({
      url: app.globalData.apiurl + "slider",
      method: 'GET',
      success: res => {
        if (res.data.code == 0) {
          console.log(res)
          this.setData({
            slider: res.data.data
          })
        }
      }
    })
    //
    this.setData({
      citycenter: this.data.cityleft['地铁'],
    })
    //
    let item = this.data.items
    //类型
    wx.request({
      url: app.globalData.apiurl + "workshop_industry",
      method: 'GET',
      success: res => {
        console.log(res)
        if (res.data.code == 0) {
          this.setData({
            industryList: res.data.data
          })
        }
      }
    })
    //行业
    wx.request({
      url: app.globalData.apiurl + "workshop_hangye",
      method: 'GET',
      success: res => {
        console.log(res)
        if (res.data.code == 0) {

          this.setData({
            hangyeList: res.data.data
          })
        }
      }
    })
    //标签
    wx.request({
      url: app.globalData.apiurl + "workshop_tag",
      method: 'GET',
      success: res => {
        console.log(res)
        if (res.data.code == 0) {
          this.setData({
            tagsList: res.data.data
          })
        }
      }
    })

    this.setData({
        area:options.area
    })
    this.loadpage()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  selectPurpose: function (e) {
    console.log(e.currentTarget.dataset.index)
    let purposeList = this.data.purposeList
    let selectPurpose = this.data.selectPurpose

    if (selectPurpose[e.currentTarget.dataset.index] === true) {
      console.log(11)
      selectPurpose[e.currentTarget.dataset.index] = false
    } else {
      selectPurpose = [];//改成单选卧槽  
      selectPurpose[e.currentTarget.dataset.index] = true
    }

    this.setData({
      selectPurpose: selectPurpose
    })
  },
  
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.setData({
      pull: true,
      page: 0,
      hangye: 0,
      industry: 0,
      tags: 0,
      sort_key: 'id',
      sort: 'desc',
      province_id: 0,
      city_id: 0,
      qu_id: 0,
      purpose: 0,
      area: '',

    })
    this.loadpage()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.loadpage()
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: '租厂房找昊信地产',
      path: '/pages/home/home?user_id=' + app.globalData.userInfo.user_id+'&hangye='+this.data.hangye+'&industry='+this.data.industry+'&tags='+this.data.tags+'&city_id='+this.data.city_id+'&qu_id='+this.data.qu_id+'&area='+this.data.area
    }
  },
  loadpage: function () {
    console.log(this.data.workshop_next)
 
    // 显示加载图标
    this.setData({
      show: true
    })
    let floor=this.data.floor
    let workshops = this.data.workshop
    let page = this.data.page
    let industry = this.data.industry
    let tags = this.data.tags
    let sort_key = this.data.sort_key
    let sort = this.data.sort
    let hangye = this.data.hangye
    let province_id = this.data.province_id
    let city_id = this.data.city_id
    let qu_id = this.data.qu_id
    let purpose = this.data.purpose
    let area = this.data.area
    let status = this.data.status
    wx.request({
      url: app.globalData.apiurl + "workshop_list",
      method: "GET",
      data: {
        page: page,
        hangye: hangye,
        industry: industry,
        tags: tags,
        sort_key: sort_key,
        sort: sort,
        province_id: province_id,
        city_id: city_id,
        qu_id: qu_id,
        purpose: purpose,
        area: area,
        status: status,
        floor:floor
      },
      success: res => {
        if (res.data.code == 0) {
          page++;
          this.setData({
            page: page
          })
          for (let i = 0; i < res.data.data.length; i++) {
            workshops.push(res.data.data[i])
          }
          this.setData({

            workshop: workshops,
            workshop_next: res.data.links.next,
            workshop_total:res.data.meta.total
          })
          if (res.data.links.next == undefined || res.data.links.next === null) {
            this.setData({
              more_title: '没有更多数据了'
            })
          
          }else{
            this.setData({
              more_title: '点击加载更多厂房...'
            })
          }
        }
        this.setData({
          show: false,
          pull: false
        })
      }
    })
  },

  //
  // 地铁区域列表下拉框是否隐藏
  listqy: function (e) {
    if (this.data.qyopen) {
      this.setData({
        qyopen: false,
        nzopen: false,
        pxopen: false,
        stopen: false,
        stshow: true,
        nzshow: true,
        pxshow: true,
        qyshow: false,
        isfull: false,
        shownavindex: 0,
        isFixed: false,
      })
    } else {
      this.setData({
        qyopen: true,
        pxopen: false,
        nzopen: false,
        stopen: false,
        stshow: true,
        nzshow: true,
        pxshow: true,
        qyshow: false,
        isfull: true,
        isFixed: true,
        shownavindex: e.currentTarget.dataset.nav
      })
    }

  },
  // 价格下拉框是否隐藏
  list: function (e) {
    if (this.data.nzopen) {
      this.setData({
        nzopen: false,
        pxopen: false,
        stopen: false,
        qyopen: false,
        stshow: true,
        nzshow: false,
        pxshow: true,
        qyshow: true,
        isfull: false,
        shownavindex: 0
      })
    } else {
      this.setData({
        content: this.data.nv,
        nzopen: true,
        pxopen: false,
        stopen: false,
        qyopen: false,
        stshow: true,
        nzshow: false,
        pxshow: true,
        qyshow: true,
        isfull: true,
        shownavindex: e.currentTarget.dataset.nav
      })
    }
  },
  // 排序下拉框是否隐藏
  listarea: function (e) {
    console.log(this.data.nzopen)
    if (this.data.nzopen) {
      this.setData({
        nzopen: false,
        pxopen: false,
        stopen: false,
        qyopen: false,
        nzshow: true,
        pxshow: true,
        stshow: true,
        qyshow: true,
        isfull: false,
        shownavindex: 0,
        isFixed: false
      })
    } else {
      this.setData({
        stopen: false,
        nzopen: true,
        pxopen: false,
        qyopen: false,
        stshow: true,
        nzshow: false,
        pxshow: true,
        qyshow: true,
        isfull: true,
        shownavindex: e.currentTarget.dataset.nav,
        isFixed: true
      })
    }
    console.log(e.target)
  },
  // 排序下拉框是否隐藏
  listpx: function (e) {
    if (this.data.pxopen) {
      this.setData({
        nzopen: false,
        pxopen: false,
        qyopen: false,
        nzshow: true,
        pxshow: false,
        qyshow: true,
        isfull: false,
        stshow: true,
        stopen: false,
        shownavindex: 0,
        isFixed: false
      })
    } else {
      this.setData({
        content: this.data.px,
        nzopen: false,
        pxopen: true,
        qyopen: false,
        stopen: false,
        pxshow: false,
        nzshow: true,
        stshow: true,
        qyshow: true,
        isfull: true,
        shownavindex: e.currentTarget.dataset.nav,
        isFixed: true
      })
    }
    console.log(e.target)
  },
  // 排序下拉框是否隐藏
  listst: function (e) {
    if (this.data.stopen) {
      this.setData({
        nzopen: false,
        pxopen: false,
        qyopen: false,
        stopen: false,
        nzshow: true,
        pxshow: true,
        qyshow: true,
        isfull: false,
        stshow: false,
        shownavindex: 0,
        isFixed: false
      })
    } else {
      this.setData({
        nzopen: false,
        pxopen: false,
        qyopen: false,
        stopen: true,
        stshow: false,
        nzshow: true,
        pxshow: true,
        qyshow: true,
        isfull: true,
        shownavindex: e.currentTarget.dataset.nav,
        isFixed: true
      })
    }
    console.log(e.target)
  },
  // 地铁区域第一栏选择内容
  selectleft: function (e) {
    console.log('用户选中左边菜单栏的索引值是：' + e.target.dataset.city);
    let title = ''
    if (e.target.dataset.city !== '') {
      title = this.data.cityleft[e.currentTarget.dataset.city].children
    }
    this.setData({
      cityright: {},
      citycenter: title,
      select1: e.target.dataset.city,
      select2: ''
    });
  },
  // 地铁区域中间栏选择的内容
  selectcenter: function (e) {
    let title = ''
    if (e.target.dataset.city !== '') {
      title = this.data.citycenter[e.currentTarget.dataset.city].children
    }
    this.setData({
      cityright: title,
      // cityright: this.data.citycenter[e.currentTarget.dataset.city],
      select2: e.target.dataset.city
    });
  },

  // 地铁区域左边栏选择的内容
  selectright: function (e) {
    console.log('选中地铁线下的地铁站' + e.currentTarget.dataset.city);
    this.setData({
      select3: e.currentTarget.dataset.city
    });
  },
  // 点击灰色背景隐藏所有的筛选内容
  hidebg: function (e) {
    this.setData({
      qyopen: false,
      nzopen: false,
      pxopen: false,
      stopen: false,
      stshow: true,
      nzshow: true,
      pxshow: true,
      qyshow: true,
      isfull: false,
      isFixed: false,
      shownavindex: 0,
    })
  },
  // 地铁区域清空筛选项
  quyuEmpty: function () {
    this.setData({
      select1: '',
      select2: '',
      select3: '',
      city_id: 0,
      qu_id: 0,
      quyu_title: '区镇'
    })
  },
  // 地铁区域选择筛选项后，点击提交
  submitFilter: function () {
    console.log('选择的一级选项是：' + this.data.select1);
    console.log('选择的二级选项是：' + this.data.select2);
    console.log('选择的三级选项是：' + this.data.select3);
    let city_id = 0
    let qu_id = 0
    let quyu_title = '区镇'
    if (this.data.select1 !== '') {
      city_id = this.data.cityleft[this.data.select1].id
      quyu_title = this.data.cityleft[this.data.select1].title
    }
    if (this.data.select2 !== '') {
      qu_id = this.data.cityleft[this.data.select1].children[this.data.select2].id
      quyu_title = this.data.cityleft[this.data.select1].children[this.data.select2].title
    }
    // 隐藏地铁区域下拉框
    this.setData({
      qyopen: false,
      nzopen: false,
      pxopen: false,
      stopen: false,
      nzshow: true,
      pxshow: true,
      stshow: true,
      qyshow: false,
      isfull: false,
      shownavindex: 0,
      isFixed: false,
      city_id: city_id,
      qu_id: qu_id,
      page: 1,
      workshop: [],
      quyu_title: quyu_title
    })
    this.loadpage()
  },
  // 左边滑块滑动的值
  leftSchange: function (e) {
    console.log('左边改变的值为：' + e.detail.value);
    let currentValue = parseInt(e.detail.value);
    let currentPer = parseInt(currentValue)
    var that = this;
    that.setData({
      leftValue: e.detail.value //设置左边当前值
    })
  },
  // 右边滑块滑动的值
  rightSchange: function (e) {
    console.log('右边改变的值为：' + e.detail.value);
    let currentValue = parseInt(e.detail.value);
    var that = this;
    that.setData({
      rightValue: e.detail.value,
    })
  },
  // 价格筛选框重置内容
  priceEmpty: function () {
    this.setData({
      leftValue: 1000, //左边滑块默认值
      rightValue: 6000, //右边滑块默认值
    })
  },
  // 价格筛选框提交内容
  submitPrice: function () {
    // 隐藏价格下拉框选项
    this.setData({
      nzopen: false,
      pxopen: false,
      qyopen: false,
      stopen: false,
      stshow: true,
      nzshow: false,
      pxshow: true,
      qyshow: true,
      isfull: false,
      shownavindex: 0
    })
  },
  // 排序内容下拉框筛选
  selectPX: function (e) {
    console.log(e.currentTarget.dataset.index)

    let pxTitle = this.data.pxTitle
    let sort_key = this.data.sort_key
    let sort = this.data.sort
    if (e.currentTarget.dataset.index === '') {
      pxTitle = "状态"
      sort_key = "id"
      sort = 'desc'
    } else {
      pxTitle = this.data.px[e.currentTarget.dataset.index]
      sort_key = this.data.pxsort[e.currentTarget.dataset.index].sort_key
      sort = this.data.pxsort[e.currentTarget.dataset.index].sort
    }

    console.log('排序内容下拉框筛选的内容是' + e.currentTarget.dataset.index);
    this.setData({
      pxIndex: e.currentTarget.dataset.index,
      nzopen: false,
      pxopen: false,
      stopen: false,
      qyopen: false,
      nzshow: true,
      stshow: true,
      pxshow: false,
      qyshow: true,
      isfull: false,
      shownavindex: 0,
      isFixed: false,
      pxTitle: pxTitle,
      sort_key: sort_key,
      sort: sort,
      page: 1,
      workshop: [],
    });
    console.log('当前' + this.data.pxIndex);
    this.loadpage()
  },
  // 状态
  selectSt: function (e) {
    console.log(e.currentTarget.dataset.index)

    let status_title = this.data.status_title
    let status = this.data.status
    if (e.currentTarget.dataset.index === '') {
      status_title = "状态"
      status = ""
    } else {
      status_title = this.data.statusList[e.currentTarget.dataset.index]
      status = e.currentTarget.dataset.index
    }
    console.log('排序内容下拉框筛选的内容是' + e.currentTarget.dataset.index);
    this.setData({
      statusIndex: e.currentTarget.dataset.index,
      nzopen: false,
      pxopen: false,
      stopen: false,
      qyopen: false,
      nzshow: true,
      stshow: false,
      pxshow: true,
      qyshow: true,
      isfull: false,
      shownavindex: 0,
      isFixed: false,
      status_title: status_title,
      status: status,
      page: 1,
      workshop: [],
    });

    this.loadpage()
  },
  //选中area
  selectArea: function (e) {
    console.log(e.currentTarget.dataset.index)
    this.setData({
      areaIndex: e.currentTarget.dataset.index
    })
  },
  //清空 

  AreaEmpty: function (e) {
    this.setData({
      areaIndex: '',
      area_title: "面积",
      area: 0
    })
  },
  // 面积下拉框筛选
  submitArea: function (e) {

    let area_title = this.data.area_title
    let area = this.data.area
    let areaIndex = this.data.areaIndex

    if (areaIndex === '') {
      area_title = "面积"
      area = 0
    } else {
      area_title = this.data.areaList[areaIndex].value
      area = this.data.areaList[areaIndex].id
    }
    console.log(area)
    console.log('排序内容下拉框筛选的内容是' + areaIndex);
    this.setData({
      areaIndex: areaIndex,
      nzopen: false,
      pxopen: false,
      qyopen: false,
      stopen: false,
      stshow: true,
      nzshow: false,
      pxshow: true,
      qyshow: true,
      isfull: false,
      shownavindex: 0,
      isFixed: false,
      area_title: area_title,
      area: area,
      page: 1,
      workshop: [],
    });
    console.log('当前' + this.data.areaIndex);
    this.loadpage()
  },

  //电话
  makeCall: function (e) {

    wx.makePhoneCall({
      phoneNumber: app.globalData.userInfo.mobile
    })
  },
  /**
   * 
   */
  selectIndustry: function (e) {
    console.log(e.currentTarget.dataset.index)
    let industyList = this.data.industryList
    let selectIndustry = this.data.selectIndustry

    if (selectIndustry[e.currentTarget.dataset.index] === true) {
      console.log(11)
      selectIndustry[e.currentTarget.dataset.index] = false
    } else {
      selectIndustry = [];//改成单选卧槽    
      selectIndustry[e.currentTarget.dataset.index] = true
    }
    this.setData({
      selectIndustry: selectIndustry
    })
  },
  selectHangye: function (e) {
    console.log(e.currentTarget.dataset.index)
    let hangyeList = this.data.hangyeList
    let selectHangye = this.data.selectHangye

    if (selectHangye[e.currentTarget.dataset.index] === true) {
      console.log(11)
      selectHangye[e.currentTarget.dataset.index] = false
    } else {
      selectHangye = [];//改成单选卧槽  
      selectHangye[e.currentTarget.dataset.index] = true
    }

    this.setData({
      selectHangye: selectHangye
    })
  },
  selectTags: function (e) {
    console.log(e.currentTarget.dataset.index)
    let tagsList = this.data.tagsList
    let selectTags = this.data.selectTags

    if (selectTags[e.currentTarget.dataset.index] === true) {
      console.log(11)
      selectTags[e.currentTarget.dataset.index] = false
    } else {
      selectTags = []
      selectTags[e.currentTarget.dataset.index] = true
    }

    this.setData({
      selectTags: selectTags
    })
  },
  //筛选取消
  shaixuanEmpty: function (e) {
    this.setData({
      selectIndustry: [],
      selectHangye: [],
      selectTags: []
    })
  },
  //筛选确定
  shaixuansubmit: function (e) {
    let industryList = this.data.industryList
    let selectIndustry = this.data.selectIndustry
    let industry = []
    for (let i = 0; i < selectIndustry.length; i++) {
      if (selectIndustry[i] == true) {
        industry.push(industryList[i].value)
      }
    }
    industry = industry.join(',')
    console.log(industry)
    let hangyeList = this.data.hangyeList
    let selectHangye = this.data.selectHangye
    let hangye = []
    for (let i = 0; i < selectHangye.length; i++) {
      if (selectHangye[i] == true) {
        hangye.push(hangyeList[i].value)
      }
    }
    hangye = hangye.join(',')
    let selectPurpose = this.data.selectPurpose
    let purpose = []
    let purposeList = this.data.purposeList
    for (let i = 0; i < selectPurpose.length; i++) {
      if (selectPurpose[i] == true) {
        purpose.push(purposeList[i].value)
      }
    }
    purpose = purpose.join(',')
    let tagsList = this.data.tagsList
    let selectTags = this.data.selectTags
    let tags = []
    for (let i = 0; i < selectTags.length; i++) {
      if (selectTags[i] == true) {
        tags.push(tagsList[i].value)
      }
    }
    tags = tags.join(',')

    this.setData({
      industry: industry,
      tags: tags,
      hangye: hangye,
      nzopen: false,
      pxopen: false,
      stopen: false,
      qyopen: false,
      nzshow: true,
      stshow: false,
      pxshow: true,
      qyshow: true,
      isfull: false,
      shownavindex: 0,
      isFixed: false,
      purpose:purpose,
      page: 1,
      workshop: [],
    });

    this.loadpage()

  },


  searchFloor:function(e){
      let img1=this.data.img1
      let floor=0
      if(img1===0){
      img1=1
      floor=1
      }else{
        img1=0
      }
      this.setData({
        workshop:[],
        page: 1,
        img1:img1,
        img2:2,
        img3:4,
        img4:6,
        hangye: '',
        industry: '',
        tags: '',
        selectTags: [],
        province_id: '',
        selectArea: [],
        selectHangye: [],
        selectIndustry: [],
        city_id: '',
        qu_id: '',
        purpose: '',
        area: '',
        status: '',
        floor: floor,
        status_title: '筛选',
        quyu_title: '区镇',

        shownavindex: '',
      })
      this.loadpage()
  },
  seachIndustry: function (e) {
    let img2 = this.data.img2
    let industry = ''
    if (img2 === 2) {
      img2 = 3
      industry = '3'
    } else {
      img2 = 2
    }
    this.setData({
      workshop: [],
      page: 1,
      hangye: '',
      industry: industry,
      img1: 0,
      img2: img2,
      img3: 4,
      img4: 6,
      tags: '',
      selectTags: [],
      province_id: '',
      selectArea: [],
      selectHangye: [],
      selectIndustry:[],
      city_id: '',
      qu_id: '',
      purpose: '',
      area: '',
      status: '',
      floor: 0,
      status_title: '筛选',
      quyu_title: '区镇',
      select1: '', //地铁区域选中后的第二个子菜单，默认显示地铁下的子菜单
      select2: '', //地铁区域选择部分的中间
      select3: '', //地铁区域选择部分的右边
      shownavindex: '',
    })
    this.loadpage()
  },
  seachTags: function (e) {
    let img3 = this.data.img3
    let tags = ''
    if (img3 === 4) {
      img3 = 5
      tags = '1'
    } else {
      img3 = 4
    }
    this.setData({
      workshop: [],
      page: 1,
      hangye: '',
      industry: '',
      tags: '',
      img1: 0,
      img2: 2,
      img3: img3,
      img4: 6,
      selectTags:[true],
      province_id: '',
      selectArea: [],
      selectHangye: [],
      selectIndustry: [],
      city_id: '',
      qu_id: '',
      purpose: '',
      area: '',
      status: '',

      floor: 0,
      status_title: '筛选',
      quyu_title: '区镇',
      select1: '', //地铁区域选中后的第二个子菜单，默认显示地铁下的子菜单
      select2: '', //地铁区域选择部分的中间
      select3: '', //地铁区域选择部分的右边
      pxTitle: '排序',
      shownavindex: '',
    })
    this.loadpage()
  },
  seachArea: function (e) {
    let img4 = this.data.img4
    let area = ''
    if (img4 === 6) {
      img4 = 7
      area = '1'
    } else {
      img4 = 6
    }
    this.setData({
      workshop: [],
      page: 1,
      hangye: '',
      industry: '',
      tags: '',
      selectTags: [],
      selectHangye:[],
      selectIndustry:[],
      selectArea:[true],
      province_id: '',
      city_id: '',
      qu_id: '',
      purpose: '',
      area: area,
      status: '',
      floor: 0,
      img1: 0,
      img2: 2,
      img3: 4,
      img4: img4,
      status_title: '筛选',
      quyu_title: '区镇',

      select1: '', //地铁区域选中后的第二个子菜单，默认显示地铁下的子菜单
      select2: '', //地铁区域选择部分的中间
      select3: '', //地铁区域选择部分的右边
      pxIndex: '', //排序内容下拉框，默认第一个
      pxTitle: '排序',
      shownavindex: '',
    })
    this.loadpage()
  },
  //跳转投诉看厂页面
  bindtousu: function (e) {
    let url = '/pages/tousu/tousu'
    if (!this.data.mobile) {
      wx.navigateTo({
        url: '/pages/mobile/mobile?url=' + encodeURIComponent(url),
      })
      return;
    }
    wx.navigateTo({
      url: url,
    })
  },
  previewImage:function(e){
    console.log(e)
    wx.navigateTo({
      url: '/pages/web/web?url=' + encodeURIComponent(e.currentTarget.dataset.src),
    })
  }
})